package com.rlyy.grpc.client;

import com.rlyy.grpc.component.GrpcProcessGrpc;
import com.rlyy.grpc.component.RpcRequest;
import com.rlyy.grpc.component.RpcResponse;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

/**
 * @author yuanqinglong
 * @since 2020/11/26 14:46
 */
@Service
public class GrpcClientServer {



    @GrpcClient("grpc-server")
    private GrpcProcessGrpc.GrpcProcessBlockingStub grpcStub;


    /**
     * 发送grpc请求
     * @param data 请求信息
     * @return 返回信息
     */
    public String sendMessage(final String data){
        RpcResponse handler = grpcStub.handler(RpcRequest.newBuilder().setData(data).build());
        return handler.getData();
    }


}
